package com.syedu.day13.homework2;

import org.fluttercode.datafactory.impl.DataFactory;

import java.util.Set;
import java.util.TreeSet;

/**
 * description：
 * @author Administrator
 * @date 2022/3/29 9:04
 */
public class StudentManager {
    public static void main(String[] args) {
        Set<Student> students = new TreeSet<>((o1, o2) -> {
            int result = o2.getScore().compareTo(o1.getScore());
            if (result == 0) {
                result = o1.getId().compareTo(o2.getId());
            }
            return result;
        });

        Student student = null;
        DataFactory dataFactory = new DataFactory();
        //集合添加40个学生
        for (int i = 0; i < 40; i++) {
            student = new Student(dataFactory.getName(), dataFactory.getNumberBetween(50,100));
            students.add(student);
        }

        //遍历结果
        students.forEach(System.out::println);
    }
}